var express = require("express");
var {
  createNews,
  createNewsCategory,
} = require("../controller/news/createNews");
var {
  findNewsList,
  findNewsCategoryList,
} = require("../controller/news/findNews");
var router = express.Router();

router.get("/getNews", async function (req, res, next) {
  const data = await findNewsList();
  res.json(data);
});

router.get("/getNewsCategory", async function (req, res, next) {
  const data = await findNewsCategoryList();
  res.json(data);
});

router.post("/createNews", async function (req, res, next) {
  const data = await createNews(req.body);
  res.json(data);
});

router.post("/createNewsCategory", async function (req, res, next) {
  const data = await createNewsCategory(req.body);
  res.json(data);
});

module.exports = router;
